// 方法重载

class ArrayList {
  array: any[] = [];
  constructor() {}

  add(obj: object) {
    this.array.push(obj);
  }

  remove(index: number): number;
  remove(value: object): object;
  remove(value: any) {
    this.array = this.array.filter((data, index) => {
      if (typeof value === 'number') {
        return value !== index;
      } else {
        return data !== value;
      }
    });
    return value;
  }

  show() {
    this.array.forEach((data) => {
      console.log(data);
    });
  }
}

const list = new ArrayList();
const obj1 = { name: 1 };
const obj2 = { name: 2 };
list.add(obj1);
list.add(obj2);
console.log(list.remove(1));
list.show();
